package com.ctosb.classviewer.clazz.command;

/**
 * 操作指令基类(范围指令集)
 * @Author alan
 * @Date 2020/12/30 11:32 下午
 */
public abstract class BaseScopeCommand extends BaseCommand{

    public BaseScopeCommand(short operationCode) {
        super(operationCode);
    }

    @Override
    protected boolean checkOperationCode(short operationCode) {
        return operationCode >= scopeFm() && operationCode <= scopeTo();
    }

    @Override
    protected void processIfCheckFail(short operationCode) {
        throw new UnsupportedOperationException(String.format("%s only support between %d and %d.", getClass().getSimpleName(), scopeFm(), scopeTo()));
    }

    /**
     * 操作码范围从（包含当前值）
     * @Author alan
     * @Date 2020/12/30 11:49 下午
     * @return
     */
    protected abstract short scopeFm();
    /**
     * 操作码范围从（包含当前值）
     * @Author alan
     * @Date 2020/12/30 11:49 下午
     * @return
     */
    protected abstract short scopeTo();
}
